Article Detail Page

Multilayer Perceptron Explained with a Real-Life Example and Python Code: Sentiment Analysis

This is the first article in a series dedicated to Deep Learning, a group of Machine Learning methods that has its roots dating back to the 1940’s. Deep Learning gained attention in the last decades for its groundbreaking application in areas like image classification, speech recognition, and machin


Why Deep Learning is Game Changing

It all started with a Neuron

McCulloch and Pitts neuron model. (Image by author)
Neuron and it’s different components. (Image Credits)
Example of the AND and OR logic gates (Image by author).

Perceptron

Perceptrons neuron model (left) and threshold logic (right). (Image by author)

Perceptron for Binary Classification

Perceptron’s loss function. (Image by author)
Sigmoid function (Image by author).
ReLU function. (Image by author)

Putting it all together

Perceptrons neuron model (left) and activation function (right). (Image by Author)

Multilayer Perceptron

Multilayer Perceptron. (Image by author)

Backpropagation

Multilayer Perceptron, highlighting the Feedfoward and Backpropagation steps. (Image by author)
One iteration of Gradient Descent. (Image by author)

Using Perceptron for Sentiment Analysis

Sample of guest messages. (Image by author)
TfidfVectorizer(stop_words='english', lowercase=True, norm='l1')
Python source code to run Perceptron on a corpus. (Image by author)
Mean accuracy of the Perceptron model. (Image by author)

How would MultiLayer Perceptron perform in this case?

Python source code to run MultiLayer Perceptron on a corpus. (Image by author)
Mean accuracy of the Multilayer Perceptron model with 3 hidden layers, each with 2 nodes. (Image by author)
buildMLPerceptron(train_features, test_features, train_targets, test_targets, num_neurons=5)
Mean accuracy of the Multilayer Perceptron model with 3 hidden layers, each with 5 nodes. (Image by author)

Conclusion

References

You've Landed On Extra Crunch Exclusive

MonthlyMembershipTrial

AnnualMembershipSave $80

2 YearMembershipBest Deal

Membership Benefits

  • Curated Datasets.
  • Data-driven Economic and Political Intelligence.
  • Exclusive Insights (breaking news, Exposés and Investigative Research).
  • Full access to real-time Economic and Political Intelligence.
  • Curated dossiers.
  • Bespoke reports.
Additional Terms and Conditions Apply

MOST POPULAR

How Can We Help?

Please select a topic below related to your inquiry. if you don't find what you need, fill what you need, fill out contact form.

Contact Information

  • Anang Tawiah
    14 Wall Street Manhattan
    20th floor
    New York, NY 10005
  • +1 (551) 800-2125
  • info@anangtawiah.com